package com.zitangkou.user.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zitangkou.user.domain.IRoleDomainService;
import com.zitangkou.user.domain.RoleDomain;
import com.zitangkou.user.info.RoleInfo;
import com.zitangkou.user.info.converter.IRoleInfoConverter;
import com.zitangkou.user.req.role.AddRoleReq;
import com.zitangkou.user.req.role.EditRoleReq;
import com.zitangkou.user.req.role.GetRoleByPageReq;
import com.zitangkou.user.service.IRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 用户角色
 *
 * @author Deng Ningning
 * @version 1.0
 * @date 2020/8/31 16:39
 */

@Slf4j
@Service
public class RoleServiceImpl implements IRoleService {

    @Autowired
    private IRoleDomainService roleDomainService;

    @Resource
    private IRoleInfoConverter roleInfoConverter;

    /**
     * 分页查询企业
     *
     * @param req
     * @return com.zitangkou.common.global.PageResp<com.zitangkou.user.model.entity.UserRole>
     * @author Deng Ningning
     * @date 2020/9/1 17:19
     */
    @Override
    public IPage<RoleInfo> getRolePage(GetRoleByPageReq req) {
        IPage<RoleDomain> page =
                roleDomainService.selectPageByConditions(req.getCurrent(), req.getSize(), req.getKeyword(), req.getStatus());
        return new Page<RoleInfo>().setCurrent(page.getCurrent()).setSize(page.getSize())
                .setRecords(roleInfoConverter.toInfoList(page.getRecords()))
                .setTotal(page.getTotal());
    }

    @Override
    public boolean insertRole(AddRoleReq req) {
        return false;
    }

    @Override
    public boolean updateRole(EditRoleReq req) {
        return false;
    }

    @Override
    public boolean deleteRole(String userRoleId) {
        return false;
    }

    @Override
    public RoleInfo selectById(String roleId) {
        return roleInfoConverter.toInfo(roleDomainService.getRoleById(roleId));
    }
}
